﻿using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.TextEditor.Document;
using System.IO;
using System.Reflection;
using System.Xml;

namespace QuickNotepad
{
    class SyntaxModeProviders : ISyntaxModeFileProvider
    {
        private List<SyntaxMode> syntaxModes = null;

        public ICollection<SyntaxMode> SyntaxModes
        {
            get
            {
                return this.syntaxModes;
            }
        }

        public SyntaxModeProviders()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream syntaxModeStream = asm.GetManifestResourceStream("QuickNotepad.SyntaxLanguages.SyntaxModes.xml");

            if (syntaxModeStream != null)
                this.syntaxModes = SyntaxMode.GetSyntaxModes(syntaxModeStream);
            else
                this.syntaxModes = null;
        }

        public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode)
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream stream = asm.GetManifestResourceStream("QuickNotepad.SyntaxLanguages." + syntaxMode.FileName);

            return new XmlTextReader(stream);
        }

        public void UpdateSyntaxModeList()
        {
            // nil
        }
    }
}
